<?php
require_once("vcl/vcl.inc.php");
require_once("lib/db_connection.php");
//Includes
use_unit("forms.inc.php");
use_unit("extctrls.inc.php");
use_unit("stdctrls.inc.php");

//Class definition
class user_access_level_create extends Page
{
       public $Image1 = null;
       public $cmbSettings = null;
       public $Label6 = null;
       public $cmbRoute = null;
       public $cmbTire = null;
       public $cmbPart = null;
       public $cmbVehicle = null;
       public $edLevelName = null;
       public $btnCancel = null;
       public $btnSubmit = null;
       public $Label5 = null;
       public $Label4 = null;
       public $Label2 = null;
       public $Label3 = null;
       public $Label1 = null;
       function btnSubmitClick($sender, $params)
       {
       $query_insert = "INSERT INTO accounts_access_level
       (company_id,account_level,vehicle,part,tire,route,settings) VALUES
       (
       '".$_SESSION["company_id"]."',
       '".$this->edLevelName->Text."',
       '".$this->cmbVehicle->getItemIndex()."',
       '".$this->cmbPart->getItemIndex()."',
       '".$this->cmbTire->getItemIndex()."',
       '".$this->cmbRoute->getItemIndex()."',
       '".$this->cmbSettings->getItemIndex()."'
       )";
       if(mysql_query($query_insert))
       echo "<script type='text/javascript'>
       window.opener.location.reload();
       var answer = confirm('Add another record?');
       if(answer)
       {
       window.location.href='user_access_level_create.php';
       }
       else
       {
       window.close();
       }
       </script>";
       else
       die("INSERT ACCESS LEVEL ".mysql_error());
       }

       function user_access_level_createJSUnload($sender, $params)
       {

       ?>
       window.opener.location.reload();

       <?php

       }

       function btnCancelJSClick($sender, $params)
       {

       ?>
       window.close();

       <?php

       }

       function user_access_level_createCreate($sender, $params)
       {
       $this->edLevelName->Text = '';
       $this->cmbVehicle->setItemIndex('1');
       $this->cmbPart->setItemIndex('1');
       $this->cmbTire->setItemIndex('1');
       $this->cmbRoute->setItemIndex('1');
       $this->cmbSettings->setItemIndex('1');
       }

}

global $application;

global $user_access_level_create;

//Creates the form
$user_access_level_create=new user_access_level_create($application);

//Read from resource file
$user_access_level_create->loadResource(__FILE__);

//Shows the form
$user_access_level_create->show();

?>